package kr.co.tomatosystem.pdetools.shell.internal;

import java.util.HashMap;
import java.util.Map;

import org.eclipse.core.runtime.Platform;
import org.eclipse.ui.AbstractSourceProvider;

/**
 * Core Expression에 "platform" 변수를 공급합니다. 값은 {@link Platform} 클래스입니다.
 * 
 * @see PlatformPropertyTester2
 * 
 * @author Jeeeyul
 * 
 */
public class PlatformProvider extends AbstractSourceProvider {
    private static final String VARIABLE_PLATFORM = "platform"; //$NON-NLS-1$
    private Map<String, Object> state;

    public PlatformProvider() {
    }

    @Override
    public void dispose() {
        if (this.state != null) {
            this.state.clear();
            this.state = null;
        }
    }

    @SuppressWarnings("rawtypes")
    @Override
    public Map getCurrentState() {
        if (this.state == null) {
            this.state = new HashMap<String, Object>();
            this.state.put(VARIABLE_PLATFORM, Platform.class);
        }
        return this.state;
    }

    @Override
    public String[] getProvidedSourceNames() {
        return new String[] { VARIABLE_PLATFORM };
    }

}
